package com.yuntsg.nnsfcp.common.beans;

import lombok.Data;

import java.io.Serializable;

/**
 * @author baolaiqiang
 * 2019年01月01日20:58:56
 */
@Data
public class ResultBean<T> implements Serializable {

    public static final int UNKNOWN_EXCEPTION = -99;
    public static final int SUCCESS = 0;
    public static final int NO_LOGIN = -98;
    public static final int NO_PERMISSION = 2;
    public static final int CHECK_FAIL = 3;
    //手机验证码不对
    public static final int CHECKSMS = 4;
    public static final int NO_RESUTL = 10;
    private static final long serialVersionUID = 1L;
    private String msg = "success";

    private int code = SUCCESS;

    private T data;

    /**
     * 本项目临时定义--用于判断是来自baidu还是google
     */
    private int type;

    public ResultBean(String msg, int code, T data) {
        this.msg = msg;
        this.code = code;
        this.data = data;
    }

    public ResultBean() {
        super();
    }

    public ResultBean(T data) {
        super();
        this.data = data;
    }

    public ResultBean(Throwable e) {
        super();
        //msg的信息可以通过e的类型判定并输出.
        this.msg = e.toString();
        this.code = UNKNOWN_EXCEPTION;
    }

    public ResultBean(int code, String msg) {
        this.msg = msg;
        this.code = code;
    }


}
